package k8s

// CreateConfigMapRequest 创建ConfigMap请求结构体
type CreateOrUpdateConfigMapFromYamlRequest struct {
	YamlStr string `json:"yaml_str" validate:"required"` // ConfigMap JSON字符串
}

// NewDefaultCreateOrUpdateConfigMapFromYamlRequest 创建默认的CreateConfigMap请求
func NewDefaultCreateOrUpdateConfigMapFromYamlRequest() *CreateOrUpdateConfigMapFromYamlRequest {
	return &CreateOrUpdateConfigMapFromYamlRequest{}
}

// NewCreateOrUpdateConfigMapFromYamlRequest 创建CreateConfigMap请求
func NewCreateOrUpdateConfigMapFromYamlRequest(configMapYaml string) *CreateOrUpdateConfigMapFromYamlRequest {
	return &CreateOrUpdateConfigMapFromYamlRequest{
		YamlStr: configMapYaml,
	}
}

type GetConfigMapRequest struct {
	Name string `json:"name" validate:"required"` // ConfigMap名称
}

func NewDefaultGetConfigMapRequest() *GetConfigMapRequest {
	return &GetConfigMapRequest{}
}

func NewGetConfigMapRequest(name string) *GetConfigMapRequest {
	return &GetConfigMapRequest{
		Name: name,
	}
}

// CreateOrUpdateConfigMapFromJsonRequest 更新ConfigMap请求结构体
type CreateOrUpdateConfigMapFromJsonRequest struct {
	ConfigMapJson string `json:"config_map_json" validate:"required"` // ConfigMap JSON字符串
}

// NewDefaultCreateOrUpdateConfigMapFromJsonRequest 创建默认的UpdateConfigMap请求
func NewDefaultCreateOrUpdateConfigMapFromJsonRequest() *CreateOrUpdateConfigMapFromJsonRequest {
	return &CreateOrUpdateConfigMapFromJsonRequest{}
}

// NewCreateOrUpdateConfigMapFromJsonRequest 创建UpdateConfigMap请求
func NewCreateOrUpdateConfigMapFromJsonRequest(configMapJson string) *CreateOrUpdateConfigMapFromJsonRequest {
	return &CreateOrUpdateConfigMapFromJsonRequest{
		ConfigMapJson: configMapJson,
	}
}

type CreateOrUpdateConfigMapFromFilesRequest struct {
	ConfigMap string `json:"configmap" validate:"required"`
	FileMap   map[string][]byte
}

func NewDefaultCreateOrUpdateConfigMapFromFilesRequest() *CreateOrUpdateConfigMapFromFilesRequest {
	return &CreateOrUpdateConfigMapFromFilesRequest{
		FileMap: make(map[string][]byte),
	}
}
func NewCreateOrUpdateConfigMapFromFilesRequest(configMap string) *CreateOrUpdateConfigMapFromFilesRequest {
	return &CreateOrUpdateConfigMapFromFilesRequest{
		ConfigMap: configMap,
		FileMap:   make(map[string][]byte),
	}
}

func (r *CreateOrUpdateConfigMapFromFilesRequest) AddFile(key string, value []byte) {
	r.FileMap[key] = value
}

type ListConfigMapRequest struct {
	UseAnd bool              `json:"use_and"`
	Labels map[string]string `json:"labels" validate:"required"`
}

func NewDefaultListConfigMapRequest() *ListConfigMapRequest {
	return &ListConfigMapRequest{
		Labels: make(map[string]string),
	}
}
func (r *ListConfigMapRequest) AddLabel(key, value string) {
	r.Labels[key] = value
}

// DeleteConfigMapRequest 删除ConfigMap请求结构体
type DeleteConfigMapRequest struct {
	Name string `json:"name" validate:"required"` // ConfigMap名称
}

// NewDefaultDeleteConfigMapRequest 创建默认的DeleteConfigMap请求
func NewDefaultDeleteConfigMapRequest() *DeleteConfigMapRequest {
	return &DeleteConfigMapRequest{}
}

// NewDeleteConfigMapRequest 创建DeleteConfigMap请求
func NewDeleteConfigMapRequest(name string) *DeleteConfigMapRequest {
	return &DeleteConfigMapRequest{
		Name: name,
	}
}
